package cn.s1995.sloth.bizs.oo.req;

import cn.s1995.sloth.bizs.constant.RegCst;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

/**
 * VerifyREQ
 *
 * @author Lex
 * @description
 * @date 2024/01/11 15:17
 */
@Data
@Schema(name = "VerifyREQ", description = "验证")
public class VerifyREQ {

    /**
     * 校验分组
     */
    public class ValidGroup {
        /**
         * 邮箱-发送验证码
         */
        public interface EmailSend {};

        /**
         * 短信-发送验证码
         */
        public interface SmsSend {};

        /**
         * 邮箱-验证
         */
        public interface EmailVerification {};

        /**
         * 短信-验证
         */
        public interface SmsVerification {};
    }


    /**
     * 类型：1.邮箱验证 2.短信验证
     */
    @Schema(description = "类型：1.邮箱验证 2.短信验证")
    @NotNull
    @Range(min = 1, max = 2)
    private Integer type;

    /**
     * 场景：1.注册 2.忘记密码 3.修改密码 4.修改手机号
     */
    @Schema(description = "场景：1.注册 2.忘记密码 3.修改密码 4.修改手机号")
    @NotNull
    @Range(min = 1, max = 4)
    private Integer scene;

    /**
     * 国家码
     */
    @Schema(description = "国家码")
    @NotNull(groups = {ValidGroup.SmsSend.class, ValidGroup.SmsVerification.class})
    private Integer code;

    /**
     * 手机
     */
    @Schema(description = "手机")
    @NotNull(groups = {ValidGroup.SmsSend.class, ValidGroup.SmsVerification.class})
    private String mobile;

    /**
     * 邮箱
     */
    @Schema(description = "邮箱")
    @NotNull(groups = {ValidGroup.EmailSend.class, ValidGroup.EmailVerification.class})
    @Email
    private String email;

    /**
     * 邮箱
     */
    @Schema(description = "验证码")
    @NotNull(groups = {ValidGroup.EmailVerification.class, ValidGroup.SmsVerification.class})
    @Pattern(regexp = RegCst.VERIFICATION_CODE)
    private String verificationCode;
}
